import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:get/instance_manager.dart';
import 'package:industry_net/base/component/hud/controller.dart';
import 'package:industry_net/base/component/hud/hud.dart';

class HudView extends StatelessWidget {
  HudView({Key? key, required this.controller}) : super(key: key) {
    Get.put(controller);
  }
  final HudController controller;

  @override
  Widget build(BuildContext context) {
    bool isActive = controller.isShowActive.value;
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Obx(() => Container(
              constraints: BoxConstraints(
                  minWidth: isActive ? 70.r : 40.r,
                  maxWidth: isActive ? 120.r : 200.r,
                  minHeight: isActive ? 70.r : 30.r),
              padding: EdgeInsets.symmetric(
                  horizontal: 10.w, vertical: isActive ? 12.r : 5.h),
              decoration: BoxDecoration(
                  color: Colors.black54,
                  borderRadius: BorderRadius.circular(isActive ? 10.r : 5.r)),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Visibility(
                    visible: isActive,
                    child: Theme(
                        data: ThemeData(
                            cupertinoOverrideTheme: const CupertinoThemeData(
                                brightness: Brightness.dark)),
                        child: CupertinoActivityIndicator(
                          radius: 12.r,
                        )),
                  ),
                  Visibility(
                    visible: (controller.toast.value != '' && isActive),
                    child: SizedBox(
                      height: 6.r,
                    ),
                  ),
                  Visibility(
                    visible: controller.toast.value != '',
                    child: Text(
                      controller.toast.value,
                      style: TextStyle(color: Colors.white, fontSize: 11.sp),
                    ),
                  )
                ],
              ),
            ))
      ],
    );
  }
}
